import {ref} from "vue";

export function useFetch(url: string, param: any = {}) {
    const data = ref(null);
    const error = ref(null);
    fetch(url, param)
        .then((res) => res.json())
        .then((json) => data.value = json)
        .catch((err) => error.value = err);
    return {data, error};
}